#!/bin/sh
echo "Stopping Django server"
# Use ps aux and grep to get pid of django server and kill'em all.
# Only safe if there are only one server running.
kill -9 $(ps aux | grep python\ manage.py\ runserver | grep -v grep | awk '{print $2}')

echo "Stopping Redis server"
# Kill node redis server
kill -9 $(ps aux | grep redis-server | grep -v grep | awk '{print $2}')

echo "Stopping Node server"
# Kill node server
kill -9 $(ps aux | grep node\ node_server/lib/index.js | grep -v grep | awk '{print $2}')
kill -9 $(ps aux | grep node\ node_server/lib/chat.js | grep -v grep | awk '{print $2}')

echo "All services stopped"
